//app.js
import request from './utils/config.js';
App({
  onLaunch: function () {
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        console.log(res)
        this.globalData.code = res.code;
      }
    })
  },
  globalData: {
    userInfo: null,
    persionalInfo:null,
    userExt:{},//用户扩展信息
    openid:"",
    code:"",
    session_key:"",
    appid: "wxb70cce7f9a8afb10",
    qrData: null,
    goQrcodeUrl:null,
    encryptedData:"",
    iv:"",
    unionid:"",
    toolContentDet:"",
    toolTitle:"",
    sessionId:"",
    mobileNo:"",
    userName:"",
    newMessageList:"",
    caseInfoList:"",
    caseTempData:"",
    shareList:new Array(),
    winhc_oss_url: 'https://winhc.oss-cn-shanghai.aliyuncs.com/',
    old_winhc_oss_url: 'http://winhc.oss-cn-shanghai.aliyuncs.com/',
    bankInfo:{},//用户银行信息
    entrustCaseDet:{},
    entrustSuccessData:{},
    identity:""
  },

  getAuthUserInfo:function(successFn,failFn){
    wx.getSetting({
      success: res => {
        wx.getUserInfo({
          success: res => {
            successFn(res)
          },
          fail: res => {
            failFn(res)
          }
        })
      },
      fail: function () {
        wx.showModal({
          title: '系统提示',
          content: '网络错误',
          confirmText: '确定',
          confirmColor: '#35ca14',
          showCancel: false,
          success: function (res) {
            if (res.confirm) {
            }
          }
        })
      }
    })
  },
  
  onShow: function (ops){
    // console.log("开始经来获取数据", ops)
    // if (ops.scene == 1044) {
    //   console.log("获取shareTicket的值",ops.shareTicket);
    //   if (res.shareTickets) {
    //     // 获取转发详细信息
    //     wx.getShareInfo({
    //       shareTicket: res.shareTickets[0],
    //       success(res) {
    //         res.errMsg; // 错误信息
    //         res.encryptedData; // 解密后为一个 JSON 结构（openGId  群对当前小程序的唯一 ID）
    //         res.iv; // 加密算法的初始向量
    //       },
    //       fail() { },
    //       complete() { }
    //     });
    //   }
    // }
  }
  
})